home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1998 August: Tool Chest / Dev.CD Aug 98 TC.toast / Tool Chest / Testing & Debugging / Virtual User / Virtual User Current Release / Examples / Example Scripts / LocalizeDriver.vu < prev    next >
Encoding:
Text File  |  1998-06-04  |  6.0 KB  |  235 lines  |  [TEXT/MPS ]

  1. #
  2. #    File:        LocalizeDriver.vu
  3. #
  4. #    Contains:    Test script for Localized versions of Systems 7 and MacWrite II
  5. #
  6. #    Written by:    David Gaxiola
  7. #
  8. #    Copyright © 1992, Apple Computer, Inc. All rights reserved
  9. #
  10. #                 7/20/92        DGG        Created
  11. #                 3/4/96            JC        Commented out while loop in main script.
  12. #    To do:
  13. #
  14.  
  15.  
  16. Libraries "MWLocal.vu","UtilityTasks.vulib";
  17.  
  18. (************************************************************************************
  19. * Task FindFileLocal(fileName)
  20. *    This task will find a file using the "Find…" menu item in the File menu, using
  21. *    name contains and on all disks at once.  It assumes that the Finder is currently
  22. *    running.
  23. ************************************************************************************)
  24. task FindFileLocal(fileName := "")
  25. begin
  26.  
  27.     global gFindName;
  28.     global gOnDesktopString;
  29.     
  30.     foundFile := true;
  31.  
  32.     select [menuItem t:/{gFindName}≈/ m:2];
  33.     while (not match [window t:/{gFindName}≈/])
  34.         wait(1);
  35.     type k:{ fileName };
  36.     select [button t:gFindName w:1];
  37.  
  38.     stillSearching := true;
  39.     # A search may not find anything or it may take a long time.  This is one way 
  40.     # of dealing with the different outcomes.
  41.     while stillSearching
  42.     begin
  43.         wait(2);
  44.         thisWindow := match [window o:1];
  45.         if (thisWindow.s = dialog)
  46.             stillSearching := false;
  47.         else if (thisWindow.t = gFindName)
  48.             stillSearching := true;
  49.         else
  50.             stillSearching := false;
  51.     end;
  52.  
  53.     if (thisWindow.s = dialog)
  54.     begin
  55.         if not (match [staticText t:/“{fileName}” {gOnDestopString}≈/ w:[window s:dialog o:1]])        
  56.             foundFile := false;
  57.         select [button t:"Ok" w:[window o:1]];
  58.     end;
  59.     
  60.     return foundFile;
  61. end;
  62.  
  63. (************************************************************************************
  64. * Task LaunchAppInSystem7Local( appName, launchWait, closeWindow, CDEV )
  65. *    Check for app running and/or attempt to get there by:
  66. *    Using Finder's Find command to select the App, then using the open command.
  67. *    ( This works only under System 7.0 )
  68. *    launchWait is the number of seconds to wait before checking for successful
  69. *    launch of the application.
  70. ************************************************************************************)
  71. task LaunchAppInSystem7Local( appName := "", launchWait := 6, closeWindow := true, 
  72.                         CDEV := false )
  73. begin
  74.  
  75.     global gOpenName;
  76.     
  77.     if (not CDEV)
  78.         match [application t:?frontApp]!;
  79.     else
  80.         match [window t:?frontApp o:1]!;
  81.         
  82.     if (not (frontApp = appName)) 
  83.     begin
  84.         if not (TwitchAppInSystem7(appName))
  85.         begin
  86.             TwitchAppInSystem7();
  87.             if (FindFileLocal(appName))
  88.             begin
  89.                 if closeWindow
  90.                     pressKey k:{optionKey};
  91.                 select [menuItem t:gOpenName m:[menu o:2]];
  92.                 if closeWindow
  93.                     releaseKey k:{optionKey};
  94.                 wait(launchWait);
  95.  
  96.                 if (not CDEV)
  97.                 begin
  98.                     match[application t:?frontApp]!;
  99.                     if not (frontApp ~= /≈{appName}≈/) 
  100.                     begin
  101.                         println "### Failed to launch ", appName;
  102.                         return false;
  103.                     end;
  104.                 end;
  105.                 else 
  106.                 begin
  107.                     match [window t:?frontCDEV o:1];
  108.                     if not (frontCDEV ~= /≈{appName}≈/)
  109.                     begin
  110.                         println "### Failed to launch ", appName;
  111.                         return false;
  112.                     end;
  113.                 end;
  114.             end;
  115.             else
  116.             begin
  117.                 println "### Failed to find ", appName;
  118.                 println "### Failed to launch ", appName;
  119.                 return false;
  120.             end;
  121.         end;        
  122.     end;
  123.     println "### Launched ", appName;
  124.     return true;
  125. end; #LaunchAppInSystem7
  126.  
  127. (************************************************************************************
  128. * Task SetViewsControlPanel
  129. ************************************************************************************)
  130. task SetViewsControlPanel( ShowDiskInfo := true, TextFont := "Geneva", TextSize := 9  )
  131. begin
  132.     global gViewsName;
  133.     global gDiskInfoString;
  134.  
  135.     LaunchAppInSystem7Local(gViewsName,,,true);
  136.  
  137.     #    Set the "Show disk info in header" check box
  138.     if ShowDiskInfo
  139.     begin
  140.         if match [checkBox t:gDiskInfoString s:{ 0, 1 } ]!
  141.             select [checkBox t:gDiskInfoString ];
  142.     end;
  143.     else
  144.     begin
  145.         if match[ checkBox t:gDiskInfoString s:{ 1, 1 } ]!
  146.             Select [checkBox t:gDiskInfoString ];
  147.     end;
  148.  
  149.     #    Select medium size icons
  150.     match [window o:1 r:?wRect];
  151.     move a:{wRect[1] + 93, wRect[2]+187};
  152.     click;
  153.     
  154.     wait(2);
  155.     
  156.     #    Select 'Geneva' font
  157.     select [menuItem t:TextFont m:[popup w:1]];
  158.  
  159.     #    Select '9' font size
  160.     select [menuItem t:/{TextSize}/ m:[popup w:1]];
  161.  
  162.     UseKeyboardEquivalent("w");
  163. end; 
  164.  
  165. (************************************************************************************
  166. * Task SetKeyboardControlPanel
  167. ************************************************************************************)
  168. task SetKeyboardControlPanel()
  169. begin
  170.     global gKeyboardName;
  171.     
  172.     LaunchAppInSystem7Local(gKeyboardName,,,true);
  173.  
  174.     #    Click the Off radio button
  175.     match [window o:1 r:?wRect];
  176.     move a:{wRect[1] + 140, wRect[2] + 50};
  177.     click;
  178.     
  179.     #    Close the Window
  180.     UseKeyboardEquivalent("w");
  181. end; 
  182.  
  183. (************************************************************************************
  184. * Script DemoControllerMain()
  185. ************************************************************************************)
  186. script DemoControllerMain()
  187. begin
  188.     localVersion := getLocalVersion();
  189.  
  190.     usaCDEVID := 128;
  191.     usaFinderID := 130;
  192.     usaViewsID := 132;
  193.     espCDEVID := 129;
  194.     espFinderID := 131;
  195.     espViewsID := 133;
  196.     
  197.     if (localVersion = "USA")
  198.     begin
  199.         cdevID := usaCDEVID;
  200.         finderID := usaFinderID;
  201.         viewsID := usaViewsID;
  202.     end;
  203.     else if (localVersion = "Spanish")
  204.     begin
  205.         cdevID := espCDEVID;
  206.         finderID := espFinderID;
  207.         viewsID := espViewsID;
  208.     end;
  209.     
  210.     global gCdevName := getIndString(cdevID,1);
  211.     global gViewsName := getIndString(cdevID, 2);
  212.     global gKeyboardName := getIndString(cdevID, 3);
  213.     global gOpenName := getIndString(finderID, 1);
  214.     global gFindName := getIndString(finderID, 2);
  215.     global gOnDesktopString := getIndString(finderID, 3);
  216.     global gDiskInfoString := getIndString(viewsID, 1);
  217.     
  218.     SetViewsControlPanel();
  219.     SetKeyboardControlPanel();
  220.     
  221.     
  222.     if (localVersion = "Spanish")
  223.         macWriteName := "MacWrite II - E";
  224.     else if (localVersion = "USA")
  225.         macWriteName := "MacWrite II";
  226.         
  227.     LaunchAppInSystem7Local(macWriteName);
  228.     
  229.     ## To have this script run continuously uncomment the while loop block
  230.     #while 
  231.     #begin
  232.         MWLocalMain();
  233.     #end;
  234. end;
  235.